package com.psm.listeners;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFileChooser;
import javax.swing.JTextField;

import com.psm.ui.helper.PDFFileFilter;

public class BrowsePDFActionListener implements ActionListener
{

    private Component parent;
    JTextField txtSelectPDF;

    public BrowsePDFActionListener(Component parent, JTextField txtSelectPDF)
    {
	this.parent = parent;
	this.txtSelectPDF = txtSelectPDF;
    }

    @Override
    public void actionPerformed(ActionEvent ae)
    {
	JFileChooser chooser = new JFileChooser();
	chooser = new JFileChooser();
	chooser.setFileFilter( new PDFFileFilter() );
	chooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
	if ( chooser.showOpenDialog( parent ) == JFileChooser.APPROVE_OPTION )
	{
	    txtSelectPDF.setText( chooser.getSelectedFile().getAbsolutePath() );
	    txtSelectPDF.setToolTipText( txtSelectPDF.getText() );
	}
    }

}
